package Search;

//import aima.core.search.informed.*;
//import aima.core.search.framework.*;
import aima.core.agent.Action;
//import aima.core.util.datastructure.Queue;
import aimax.osm.data.entities.MapNode;
import aimax.osm.data.impl.DefaultMapNode;
//import java.util.LinkedList;
import java.util.*;
//import java.util.PriorityQueue;

//=====================================
import aimax.*;
import aimax.osm.data.Position;
import aimax.osm.data.impl.DefaultMap;
import aimax.osm.data.impl.DefaultMapBuilder;
import aimax.osm.routing.RouteCalculator;
import aimax.osm.viewer.MapViewPane;
import parserosm.ParserOsm;


/**
 *
 * @author Corlo
 */
public class BidirectionalAStarSearch {

        private Nodo desde=null;
        private Nodo hasta=null;
        private LinkedList<Nodo> fronteraD=new LinkedList<Nodo>();
        private LinkedList<Nodo> fronteraH=new LinkedList<Nodo>();

        //private LinkedList<Nodo> visitados=new LinkedList<Nodo>();;

        public BidirectionalAStarSearch(MapNode Desde, MapNode Hasta){

            this.desde=new Nodo(Desde, null);
            this.hasta=new Nodo(Hasta, null);


        }


        public List<Action> busqueda(MapNode Desde, MapNode Hasta){
            List<Action> camino=null;
            fronteraD.add(this.desde);
            fronteraH.add(this.hasta);

            while (fronteraD.isEmpty() || fronteraH.isEmpty()){
                Nodo actualD=fronteraD.getFirst();
                fronteraD.removeFirst();
                if(fronteraD.contains(this.hasta)){
                    return camino;
                }

                


            }

   




            return camino;
        }

        public List<Position> busquedanot(long IdDesde, long IdHasta, ParserOsm mapa){
            RouteCalculator route;
            ArrayList<MapNode> locs = new ArrayList();
            List<Position> calculateRoute = new ArrayList();
            route= new RouteCalculator();
            locs.add((DefaultMapNode) mapa.getnode(IdDesde));
            locs.add((DefaultMapNode) mapa.getnode(IdHasta));
            calculateRoute = route.calculateRoute(locs, mapa.gethand(), 0);
            return calculateRoute;
        }
        
         public boolean testobjetivo(Nodo nodo, Nodo objetivo){
             if (nodo.equals(objetivo)){
                return true;
             }
             return false;
        }



}
